CFLAGS = -fpic -coverage -lm -std=c99

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

#####################
#
# My unit tests
#
#####################

unittest1: unittest1.c dominion.o rngs.o
	gcc -o unittest1 -g unittest1.c dominion.o rngs.o $(CFLAGS)

unittest2: unittest2.c dominion.o rngs.o
	gcc -o unittest2 -g unittest2.c dominion.o rngs.o $(CFLAGS)

unittest3: unittest3.c dominion.o rngs.o
	gcc -o unittest3 -g unittest3.c dominion.o rngs.o $(CFLAGS)

unittest4: unittest4.c dominion.o rngs.o
	gcc -o unittest4 -g unittest4.c dominion.o rngs.o $(CFLAGS)

cardtest1: cardtest1.c dominion.o rngs.o
	gcc -o cardtest1 -g cardtest1.c dominion.o rngs.o $(CFLAGS)

cardtest2: cardtest2.c dominion.o rngs.o
	gcc -o cardtest2 -g cardtest2.c dominion.o rngs.o $(CFLAGS)

cardtest3: cardtest3.c dominion.o rngs.o
	gcc -o cardtest3 -g cardtest3.c dominion.o rngs.o $(CFLAGS)
	
cardtest4: cardtest4.c dominion.o rngs.o
	gcc -o cardtest4 -g cardtest4.c dominion.o rngs.o $(CFLAGS)

greathallTest: greathallTest.c dominion.o rngs.o
	gcc -o greathallTest -g greathallTest.c dominion.o rngs.o $(CFLAGS)

minionTest: minionTest.c dominion.o rngs.o
	gcc -o minionTest -g minionTest.c dominion.o rngs.o $(CFLAGS)


unittestresults.out: 
	unittest1 
	./unittest1 
	gcov unittest1
        
	unittest2
	./unittest2
	gcov unittest2
        
	unittest3
	./unittest3
	gcov unittest3
        
	unittest4
	./unittest4
	gcov unittest4
        
	cardtest1
	./cardtest1
	gcov cardtest1
        
	cardtest2
	./cardtest2
	gcov cardtest2
        
	cardtest3
	./cardtest3
	gcov cardtest3
        
	cardtest4
	./cardtest4
	gcov cardtest4
        
	echo "Testing Results:" > unittestresults.out
	echo "" >> unittestresults.out  
        
	echo "unittest1.c:" >> unittestresults.out
	gcc -o unittest1 -g  unittest1.c dominion.o rngs.o $(CFLAGS)
	./unittest1 >> unittestresults.out
	gcov unittest1 >> unittestresults.out
	echo "" >> unittestresults.out  
        
	echo "unittest2.c:" >> unittestresults.out
	gcc -o unittest2 -g  unittest2.c dominion.o rngs.o $(CFLAGS)
	./unittest2 >> unittestresults.out
	gcov unittest2 >> unittestresults.out
	echo "" >> unittestresults.out  
        
	echo "unittest3.c:" >> unittestresults.out
	gcc -o unittest3 -g  unittest3.c dominion.o rngs.o $(CFLAGS)
	./unittest3 >> unittestresults.out
	gcov unittest3 >> unittestresults.out
	echo "" >> unittestresults.out  
        
	echo "unittest4.c:" >> unittestresults.out
	gcc -o unittest4 -g  unittest4.c dominion.o rngs.o $(CFLAGS)
	./unittest4 >> unittestresults.out
	gcov unittest4 >> unittestresults.out
	echo "" >> unittestresults.out  
        	
	echo "cardtest1.c:" >> unittestresults.out
	gcc -o cardtest1 -g  cardtest1.c dominion.o rngs.o $(CFLAGS)
	./cardtest1 >> unittestresults.out
	gcov cardtest1 >> unittestresults.out
	echo "" >> unittestresults.out
        
	echo "cardtest2.c:" >> unittestresults.out	
	gcc -o cardtest2 -g  cardtest2.c dominion.o rngs.o $(CFLAGS)
	./cardtest2 >> unittestresults.out
	gcov cardtest2 >> unittestresults.out
	echo "" >> unittestresults.out
        
	echo "cardtest3.c:" >> unittestresults.out
	gcc -o cardtest3 -g  cardtest3.c dominion.o rngs.o $(CFLAGS)
	./cardtest3 >> unittestresults.out
	gcov cardtest3 >> unittestresults.out
	echo "" >> unittestresults.out
        
	echo "cardtest4.c:" >> unittestresults.out
	gcc -o cardtest4 -g  cardtest4.c dominion.o rngs.o $(CFLAGS)
	./cardtest4 >> unittestresults.out
	gcov cardtest4 >> unittestresults.out
	echo "" >> unittestresults.out          

	gcov -b dominion >> unittestresults.out

randomtestcard: randomtestcard.c dominion.o rngs.o
	gcc -o randomtestcard -g randomtestcard.c dominion.o rngs.o $(CFLAGS)

randomtestadventurer: randomtestadventurer.c dominion.o rngs.o
	gcc -o randomtestadventurer -g randomtestadventurer.c dominion.o rngs.o $(CFLAGS)

randomtestcard.out: 
	randomtestcard 
	./randomtestcard 
	gcov randomtestcard
	
	echo "randomtestcard.c:" >> randomtestcard.out
	gcc -o randomtestcard -g  randomtestcard.c dominion.o rngs.o $(CFLAGS)
	./randomtestcard >> randomtestcard.out
	gcov randomtestcard >> randomtestcard.out
	echo "" >> randomtestcard.out  

randomtestadventurer.out: 
	randomtestadventurer 
	./randomtestadventurer 
	gcov randomtestadventurer
	
	echo "randomtestadventurer.c:" >> randomtestadventurer.out
	gcc -o randomtestadventurer -g  randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	./randomtestadventurer >> randomtestadventurer.out
	gcov randomtestadventurer >> randomtestadventurer.out
	echo "" >> randomtestadventurer.out  
	
all: playdom player unittestresults.out randomtestcard.out randomtestadventurer.out

clean:
	rm -f *.o playdom.exe playdom player player.exe *.gcov *.gcda *.gcno *.so

